using System;
using System.Collections;
using System.Data;
using System.Collections.Generic;
using System.Text;

namespace Alogient.Cameleon.Forms.Sdk.Items
{
    public enum FormInputType
    {
        //Button,
        Checkbox = 1,
        Date = 2,
        DateRange = 3,
        Number = 4,
        Radio = 5,
        Rating = 6,
        Select = 7,
        Text = 8,
        TextBlock = 9,
        TextArea = 10,
        Upload = 11
    }

    public class FormElement
    {
        #region Properties

        protected bool? _boolean1 = null;
        protected bool? _boolean2 = null;
        protected long? _long1 = null;
        protected long? _long2 = null;
        protected long? _long3 = null;
        protected long? _long4 = null;
        protected string _text1 = null;
        protected string _text2 = null;
        protected string _enum = null;
        protected string _textCulture1 = null;
        protected string _textCulture2 = null;
        protected string _textCulture3 = null;

        public int ID { get; protected set; }
        public int FormID { get; protected set; }
        public int PageID { get; protected set; }
        public FormStatus ElementStatus { get; protected set; }
        public int Order { get; protected set; }
        public string Name { get; protected set; }
        public string Label { get; protected set; }
        public string ToolTip { get; protected set; }
        public string CultureCode { get; protected set; }
        public FormInputType InputType { get; protected set; }
        public string CSS { get; set; }
        public bool VisibleLive { get; protected set; }
        public bool VisiblePreview { get; protected set; }
        public bool Required { get; protected set; }

        private List<FormElementChoice> _choices = null;
        public List<FormElementChoice> Choices
        {
            get
            {
                if (_choices == null)
                    _choices = loadChoices();

                return _choices;
            }
        }

        private Form _form = null;
        public Form Form
        {
            get
            {
                if (_form == null)
                    _form = new Form(FormID, CultureCode);

                return _form;
            }
        }

        #endregion

        #region Constructors

        protected FormElement()
        {
            Required = false;
            VisiblePreview = false;
            VisibleLive = false;
            CSS = string.Empty;
            InputType = FormInputType.Text;
            CultureCode = string.Empty;
            ToolTip = string.Empty;
            Label = string.Empty;
            Name = string.Empty;
            Order = 0;
            ElementStatus = FormStatus.New;
            PageID = 0;
            FormID = 0;
            ID = 0;
        }

        public FormElement(int id, string cultureCode)
        {
            Required = false;
            VisiblePreview = false;
            VisibleLive = false;
            CSS = string.Empty;
            InputType = FormInputType.Text;
            CultureCode = string.Empty;
            ToolTip = string.Empty;
            Label = string.Empty;
            Name = string.Empty;
            Order = 0;
            ElementStatus = FormStatus.New;
            PageID = 0;
            FormID = 0;
            ID = 0;

            throw new NotImplementedException("Not implemented"); // TODO
        }

        #endregion

        #region Methods

        protected bool GetBoolean(string s)
        {
            return Boolean.Parse(s);
        }
        protected int GetInt(string s)
        {
            return Int32.Parse(s);
        }
        protected DateTime GetDate(long l)
        {
            return new DateTime(l);
        }
        protected long GetLong(string s)
        {
            return long.Parse(s);
        }
        
        protected List<FormElementChoice> loadChoices()
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        
        #endregion
    }
}
